﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CSUI
{
    public partial class FormBase : Form
    {
        Point mouseOff;//鼠标移动位置变量

        bool leftFlag;//标签是否为左键

        public FormBase()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)

            {

                mouseOff = new Point(-e.X, -e.Y);

                leftFlag = true;

            }
        }

        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (leftFlag)

            {

                Point mouseSet = Control.MousePosition;

                mouseSet.Offset(mouseOff.X, mouseOff.Y);//设置移动后的位置

                Location = mouseSet;

            }
        }

        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {

                leftFlag = false;//释放鼠标后标注为False

            }
        }
    }
}
